// This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps // and qualities. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using System.Diagnostics; using OpcLabs.EasyOpc; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.DataAccess.OperationModel; namespace DocExamples.DataAccess.Xml { partial class ReadMultipleItems { public static void Main1Xml() { // Instantiate the client object. var client = new EasyDAClient(); DAVtqResult[] vtqResults = client.ReadMultipleItems( new ServerDescriptor { UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" }, new DAItemDescriptor[] { "Dynamic/Analog Types/Double", "Dynamic/Analog Types/Double[]", "Dynamic/Analog Types/Int", "SomeUnknownItem" }); for (int i = 0; i < vtqResults.Length; i++) { Debug.Assert(vtqResults[i] != null); if (!(vtqResults[i].Exception is null)) { Console.WriteLine($"vtqResults[{i}] *** Failure: {vtqResults[i].ErrorMessageBrief}"); continue; } Console.WriteLine($"vtqResults[{i}].Vtq: {vtqResults[i].Vtq}"); } } } }
# This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps # and qualities. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. #requires -Version 5.1 using namespace OpcLabs.EasyOpc using namespace OpcLabs.EasyOpc.DataAccess # The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows . Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicCore.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassic.dll" Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicComponents.dll" # Instantiate the client object. $client = New-Object EasyDAClient $serverDescriptor = New-Object ServerDescriptor -Property @{ UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" } $vtqResults = [IEasyDAClientExtension]::ReadMultipleItems($client, $serverDescriptor, @( (New-Object DAItemDescriptor("Dynamic/Analog Types/Double")), (New-Object DAItemDescriptor("Dynamic/Analog Types/Double[]")), (New-Object DAItemDescriptor("Dynamic/Analog Types/Int")), (New-Object DAItemDescriptor("SomeUnknownItem")) )) for ($i = 0; $i -lt $vtqResults.Length; $i++) { $vtqResult = $vtqResults[$i] if ($vtqResult.Succeeded) { Write-Host "vtqResults[$($i)].Vtq: $($vtqResult.Vtq)" } else { Write-Host "vtqResults[$($i)] *** Failure: $($vtqResult.ErrorMessageBrief)" } }
' This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps ' and qualities. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.EasyOpc Imports OpcLabs.EasyOpc.DataAccess Imports OpcLabs.EasyOpc.DataAccess.OperationModel Namespace DataAccess.Xml Partial Friend Class ReadMultipleItems Public Shared Sub Main1Xml() Dim client = New EasyDAClient() Dim vtqResults() As DAVtqResult = client.ReadMultipleItems( New ServerDescriptor() With {.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"}, New DAItemDescriptor() _ { _ "Dynamic/Analog Types/Double", "Dynamic/Analog Types/Double[]", "Dynamic/Analog Types/Int", "SomeUnknownItem" }) For i = 0 To vtqResults.Length - 1 Debug.Assert(vtqResults(i) IsNot Nothing) If vtqResults(i).Exception IsNot Nothing Then Console.WriteLine("vtqResult[{0}] *** Failure: {1}", i, vtqResults(i).ErrorMessageBrief) Continue For End If Console.WriteLine("vtqResult[{0}].Vtq: {1}", i, vtqResults(i).Vtq) Next i End Sub End Class End Namespace
// This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps // and qualities. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. class procedure ReadMultipleItems.MainXml; var Arguments: OleVariant; Client: OpcLabs_EasyOpcClassic_TLB._EasyDAClient; I: Cardinal; ReadItemArguments1: _DAReadItemArguments; ReadItemArguments2: _DAReadItemArguments; ReadItemArguments3: _DAReadItemArguments; ReadItemArguments4: _DAReadItemArguments; VtqResult: _DAVtqResult; Results: OleVariant; begin ReadItemArguments1 := CoDAReadItemArguments.Create; ReadItemArguments1.ServerDescriptor.UrlString := 'http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'; ReadItemArguments1.ItemDescriptor.ItemID := 'Dynamic/Analog Types/Double'; ReadItemArguments2 := CoDAReadItemArguments.Create; ReadItemArguments2.ServerDescriptor.UrlString := 'http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'; ReadItemArguments2.ItemDescriptor.ItemID := 'Dynamic/Analog Types/Double[]'; ReadItemArguments3 := CoDAReadItemArguments.Create; ReadItemArguments3.ServerDescriptor.UrlString := 'http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'; ReadItemArguments3.ItemDescriptor.ItemID := 'Dynamic/Analog Types/Int'; ReadItemArguments4 := CoDAReadItemArguments.Create; ReadItemArguments4.ServerDescriptor.UrlString := 'http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'; ReadItemArguments4.ItemDescriptor.ItemID := 'SomeUnknownItem'; Arguments := VarArrayCreate([0, 3], varVariant); Arguments[0] := ReadItemArguments1; Arguments[1] := ReadItemArguments2; Arguments[2] := ReadItemArguments3; Arguments[3] := ReadItemArguments4; // Instantiate the client object Client := CoEasyDAClient.Create; TVarData(Results).VType := varArray or varVariant; TVarData(Results).VArray := PVarArray( Client.ReadMultipleItems(Arguments)); // Display results for I := VarArrayLowBound(Results, 1) to VarArrayHighBound(Results, 1) do begin VtqResult := IInterface(Results[I]) as _DAVtqResult; if VtqResult.Exception <> nil then begin WriteLn('results[', i, '] *** Failure: ', VtqResult.ErrorMessageBrief); Continue; end; WriteLn('results[', i, '].Vtq.ToString(): ', VtqResult.Vtq.ToString); end; VarClear(Results); VarClear(Arguments); end;
// This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps // and qualities. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. $ReadItemArguments1 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments"); $ReadItemArguments1->ServerDescriptor->UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"; $ReadItemArguments1->ItemDescriptor->ItemID = "Dynamic/Analog Types/Double"; $ReadItemArguments2 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments"); $ReadItemArguments2->ServerDescriptor->UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"; $ReadItemArguments2->ItemDescriptor->ItemID = "Dynamic/Analog Types/Double[]"; $ReadItemArguments3 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments"); $ReadItemArguments3->ServerDescriptor->UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"; $ReadItemArguments3->ItemDescriptor->ItemID = "Dynamic/Analog Types/Int"; $ReadItemArguments4 = new COM("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments"); $ReadItemArguments4->ServerDescriptor->UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"; $ReadItemArguments4->ItemDescriptor->ItemID = "SomeUnknownItem"; $arguments[0] = $ReadItemArguments1; $arguments[1] = $ReadItemArguments2; $arguments[2] = $ReadItemArguments3; $arguments[3] = $ReadItemArguments4; $Client = new COM("OpcLabs.EasyOpc.DataAccess.EasyDAClient"); $results = $Client->ReadMultipleItems($arguments); for ($i = 0; $i < count($results); $i++) { $VtqResult = $results[$i]; if ($VtqResult->Succeeded) printf("results[d].Vtq.ToString()s\n", $i, $VtqResult->Vtq->ToString); else printf("results[d]: *** Failures\n", $i, $VtqResult->ErrorMessageBrief); }
Rem This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps Rem and qualities. Rem REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB . REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own REM a commercial license in order to use Online Forums, and we reply to every post. Private Sub ReadMultipleItems_MainXml_Command_Click() OutputText = "" Dim readArguments1 As New DAReadItemArguments readArguments1.serverDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" readArguments1.ItemDescriptor.ItemId = "Dynamic/Analog Types/Double" Dim readArguments2 As New DAReadItemArguments readArguments2.serverDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" readArguments2.ItemDescriptor.ItemId = "Dynamic/Analog Types/Double[]" Dim readArguments3 As New DAReadItemArguments readArguments3.serverDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" readArguments3.ItemDescriptor.ItemId = "Dynamic/Analog Types/Int" Dim readArguments4 As New DAReadItemArguments readArguments4.serverDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" readArguments4.ItemDescriptor.ItemId = "SomeUnknownItem" Dim arguments(3) As Variant Set arguments(0) = readArguments1 Set arguments(1) = readArguments2 Set arguments(2) = readArguments3 Set arguments(3) = readArguments4 ' Instantiate the client object Dim client As New EasyDAClient Dim vtqResults() As Variant vtqResults = client.ReadMultipleItems(arguments) ' Display results Dim i: For i = LBound(vtqResults) To UBound(vtqResults) Dim vtqResult As DAVtqResult: Set vtqResult = vtqResults(i) If Not (vtqResult.Exception Is Nothing) Then OutputText = OutputText & "results(" & i & ") *** Failure: " & vtqResult.ErrorMessageBrief & vbCrLf Else OutputText = OutputText & "results(" & i & ").Vtq.ToString(): " & vtqResult.vtq & vbCrLf End If Next End Sub
Rem This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps Rem and qualities. Rem Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript . Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own Rem a commercial license in order to use Online Forums, and we reply to every post. Option Explicit Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments1.ServerDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" ReadItemArguments1.ItemDescriptor.ItemID = "Dynamic/Analog Types/Double" Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments2.ServerDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" ReadItemArguments2.ItemDescriptor.ItemID = "Dynamic/Analog Types/Double[]" Dim ReadItemArguments3: Set ReadItemArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments3.ServerDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" ReadItemArguments3.ItemDescriptor.ItemID = "Dynamic/Analog Types/Int" Dim ReadItemArguments4: Set ReadItemArguments4 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments") ReadItemArguments4.ServerDescriptor.UrlString = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx" ReadItemArguments4.ItemDescriptor.ItemID = "SomeUnknownItem" Dim arguments(3) Set arguments(0) = ReadItemArguments1 Set arguments(1) = ReadItemArguments2 Set arguments(2) = ReadItemArguments3 Set arguments(3) = ReadItemArguments4 Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") Dim results: results = Client.ReadMultipleItems(arguments) Dim i: For i = LBound(results) To UBound(results) Dim VtqResult: Set VtqResult = results(i) If Not (VtqResult.Exception Is Nothing) Then WScript.Echo "results(" & i & ") *** Failure: " & VtqResult.ErrorMessageBrief Else WScript.Echo "results(" & i & ").Vtq.ToString(): " & VtqResult.Vtq.ToString() End If Next
# This example shows how to read 4 items from an OPC XML-DA server at once, and display their values, timestamps # and qualities. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from OpcLabs.EasyOpc import * from OpcLabs.EasyOpc.DataAccess import * from OpcLabs.EasyOpc.DataAccess.OperationModel import * from OpcLabs.EasyOpc.OperationModel import * # Instantiate the client object. client = EasyDAClient() # vtqResultArray = IEasyDAClientExtension.ReadMultipleItems(client, ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), [ DAItemDescriptor('Dynamic/Analog Types/Double'), DAItemDescriptor('Dynamic/Analog Types/Double[]'), DAItemDescriptor('Dynamic/Analog Types/Int'), DAItemDescriptor('SomeUnknownItem') ]) for i, vtqResult in enumerate(vtqResultArray): assert vtqResult is not None if vtqResult.Succeeded: print('vtqResultArray[', i, '].Vtq: ', vtqResult.Vtq, sep='') else: print('vtqResultArray[', i, '] *** Failure: ', vtqResult.ErrorMessageBrief, sep='')
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
Documentation Home, Send Documentation Feedback. Technical Support